#include "ctrl.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "common.h"

uint8_t ctrl_parse_str2dec(uint8_t *str, uint32_t *num)
{
	uint8_t  i;
	uint32_t tmp_num = 0;
	for (i = 0; i < CTRL_STR_NUM_LEN; i++) {
		if ((*str >= '0') && (*str <= '9')) {
				tmp_num = tmp_num * 10 + *str++ - '0';
		} else {
				break;
		}
	}
	*num = tmp_num;
	return i;
}

void *ctrl_parse_aswerr(uint8_t err)
{
	__CtrlMem *tx_mem = (__CtrlMem *)ucSendBuf;
	char tmp_data[16];
	memset(tmp_data,0,16);
	sprintf(tmp_data, "CTRL,ERR:%d;\r\n", err);
	tx_mem ->len = mystrcpy(tx_mem->data,tmp_data);
	return tx_mem;
}